package com.hg.chapter7.websocket;

import com.hg.chapter7.message.BSMessage;
import com.hg.chapter7.message.SBMessage;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;

@Controller
public class WebSocketController {

    @MessageMapping("welcome")//浏览器向服务器发送信息地址
    @SendTo("/topic/getResponse")//浏览器接收服务器地址
    public SBMessage say(BSMessage message){
        SBMessage sbMessage = new SBMessage();
        sbMessage.setMessage(message.getMessage());
        return sbMessage;
    }
}
